<template>
  <div id="personnelTrackQuery">
    <div class="dev-nav">
      <p>人员轨迹查询</p>
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>出入管理</el-breadcrumb-item>
        <el-breadcrumb-item>人员轨迹</el-breadcrumb-item>
        <el-breadcrumb-item>人员轨迹查询</el-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <div class="search">
      <el-select v-model="personnelTypeValue" filterable placeholder="人员类型">
        <el-option
          v-for="item in personnelTypeOptions"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
        </el-option>
      </el-select>
      <el-input v-model="input" placeholder="抓拍序号"></el-input>

      <!-- 日历 -->
      <div class="block">
        <!-- <span class="demonstration">默认</span> -->
        <el-date-picker
          class="block-content"
          v-model="value1"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker>
      </div>
      <!-- 查询 -->
      <el-button
        type="success"
        style="background-color: #0bb197"
        @click="inquire"
      >
        <i class="el-icon-search"></i>
        查询</el-button
      >
      <el-button
        type="success"
        plain
        style="margin-right: 0px"
        class="reset"
        @click="reset"
      >
        <i class="el-icon-refresh"></i>
        重置</el-button
      >
    </div>
    <!-- 表格内容 -->
    <div class="dev-content">
      <p>查询结果列表</p>
      <el-table :data="tableData" stripe style="width: 100%">
        <el-table-column prop="id" label="序号" width="50" align="center">
        </el-table-column>
        <el-table-column
          prop="userList.userName"
          label="人员姓名"
          width="160"
          align="center"
        >
        </el-table-column>
        <el-table-column label="人员类型" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.userList.ownerType == 2">业主</span>
            <span v-if="scope.row.userList.ownerType == 1">家庭成员</span>
            <span v-if="scope.row.userList.ownerType == 0">租客</span>
          </template>
        </el-table-column>
        <el-table-column label="是否黑名单" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.userList.userStatus == 0">否</span>
            <span v-if="scope.row.userList.userStatus == 1">是</span>
          </template></el-table-column
        >
        <el-table-column prop="cameraNumber" label="摄像机编号" align="center">
        </el-table-column>
        <el-table-column prop="cameraPlace" label="摄像机位置" align="center">
        </el-table-column>
        <el-table-column label="抓拍时间" align="center"
          ><template slot-scope="scope">
            <span>{{ timeTrans(scope.row.cameraTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="picNumber" label="抓拍序号" align="center">
        </el-table-column>
        <el-table-column width="80" label="抓拍图片" align="center">
          <template slot-scope="scope">
            <img :src="scope.row.cameraPic" v-if="scope.row.cameraPic" />
            <span v-else>暂无</span>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="120" align="center">
          <template slot-scope="scope">
            <el-button
              @click="details(scope.row)"
              type="text"
              size="small"
              style="color: #0bb197"
              >详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :background="true"
        class="msg-pagination-container"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="count"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>

    <!-- 详情弹窗 -->
    <div class="detail-pop">
      <el-dialog
        title="详细信息"
        :visible.sync="detailDialog"
        width="43%"
        class="detail"
      >
        <div class="detail-content">
          <div class="detail-content-left">
            <ul class="detail-content-ul">
              <li>
                <span>人员姓名：</span><span>{{ userName }}</span>
              </li>
              <li>
                <span>是否黑名单：</span>
                <span v-if="userStatus == 0">否</span>
                <span v-if="userStatus == 1">是</span>
              </li>
              <li>
                <span>摄像机位置：</span
                ><span>{{ detailShowData.cameraPlace }}</span>
              </li>
              <li>
                <span>抓拍序号：</span
                ><span>{{ detailShowData.picNumber }}</span>
              </li>
            </ul>
          </div>
          <div class="detail-content-right">
            <ul class="detail-content-ul">
              <li>
                <span>人员类型：</span>
                <span v-if="ownerType == 2">业主</span>
                <span v-if="ownerType == 1">家庭成员</span>
                <span v-if="ownerType == 0">租客</span>
              </li>
              <li>
                <span>摄像机编号：</span
                ><span>{{ detailShowData.cameraNumber }}</span>
              </li>
              <li>
                <span>抓拍时间：</span>
                <span>{{ timeTrans(detailShowData.cameraTime) }}</span>
              </li>
              <li>
                <span>抓拍照片：</span><img :src="detailShowData.cameraPic" />
              </li>
            </ul>
          </div>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import time from "../utils/time";
export default {
  mixins: [time],
  data() {
    return {
      page: 1,
      count: 5,
      total: 1,
      input: "",
      isPhoto: true,
      tableData: [],
      //  日历
      value1: [],
      startTime: "",
      endTime: "",
      //   人员类型
      personnelTypeOptions: [
        {
          value: 0,
          label: "租客",
        },
        {
          value: 1,
          label: "家庭成员",
        },
        {
          value: 2,
          label: "业主",
        },
      ],
      personnelTypeValue: "",
      //   通行位置
      passableLocationOptions: [
        {
          value: "待审核",
          label: "老嗷嗷",
        },
        {
          value: "选项2",
          label: "偶尔赔款",
        },
      ],
      passableLocationValue: "",
      // 详情
      detailDialog: false,
      // 详情页数据
      detailShowData: {
        cameraPlace: "",
        picNumber: "",
        alarmPic: "",
        cameraNumber: "",
        cameraTime: 0,
        cameraPic: "",
      },
      userStatus: "", //是否黑名单
      userName: "", //人员姓名
      ownerType: "", //人员类型
    };
  },
  methods: {
    handleSizeChange(val) {
      this.count = val;
      this.getData();
    },
    handleCurrentChange(val) {
      this.page = val;
      this.getData();
    },
    // 渲染
    getData() {
      this.value1[0] && (this.startTime = this.timeTrans(this.value1[0]));
      this.value1[1] && (this.endTime = this.timeTrans(this.value1[1]));
      this.$axios({
        url: "/smart/track/list",
        method: "get",
        params: {
          pageNum: this.page,
          pageSize: this.count,
          personType: this.personnelTypeValue,
          catchNo: this.input,
          startTime: this.startTime,
          endTime: this.endTime,
        },
      }).then(({ data }) => {
        // console.log("啦啦啦啦", data);
        if (data.code == 2000) {
          this.tableData = data.data.list;
          this.total = data.data.total;
        } else {
          this.$message.error("数据加载失败！");
        }
      });
    },
    // 查询
    inquire() {
      // alert("还没有查询接口");
      this.getData();
    },
    // 重置
    reset() {
      this.input = "";
      this.personnelTypeValue = [];
      this.value1 = [];
      this.startTime="";
      this.endTime="";
      this.getData();
      this.$message.success("重置成功");
    },
    // 详情
    details(val) {
      // alert("还没有详情页");
      this.detailDialog = true;
      this.detailShowData = val;
      this.userName = val.userList.userName;
      this.ownerType = val.userList.ownerType;
      this.userStatus = val.userList.userStatus;
    },
  },
  mounted() {
    this.getData();
  },
};
</script>


<style lang="less" scoped>
#personnelTrackQuery {
  padding: 20px;
  //   border: 1px solid red;
  .dev-nav {
    display: flex;
    justify-content: space-between;
  }
  p {
    font-size: 18px;
    margin: 0;
  }
  .search {
    margin: 20px 0px;
    padding: 20px 15px;
    display: flex;
    align-items: center;
    background-color: white;
    border-radius: 8px;
    .reset {
      background-color: white;
      color: #c0c4cc;
      border: 1px solid #c0c4cc;
    }
    .reset:hover {
      color: #0bb197;
    }
    .el-input {
      width: 150px;
      margin-right: 10px;
    }
    .el-select {
      margin-right: 10px;
    }
    .block {
      margin-right: 10px;
      .block-content {
        width: 310px;
      }
    }
    .el-button {
      padding: 10px 15px;
      margin-left: 0px;
      margin-right: 20px;
    }
  }
  .dev-content {
    padding: 20px 15px;
    padding-bottom: 30px;
    background-color: white;
    border-radius: 8px;
    p {
      font-size: 16px;
      margin-bottom: 10px;
    }
    .el-pagination {
      text-align: end;
      margin-top: 20px;
    }
  }
}

// 详情弹窗
.detail-content-left {
  flex: 1;
  margin-right: 70px;
  .detail-content-ul li {
height: 40px;
    margin: 15px 0px;
    list-style-type: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}
.detail-content-right {
  flex: 1;
  .detail-content-ul li {
    height: 40px;
    margin: 15px 0px;
    list-style-type: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}
</style>

<style lang="less">
.msg-pagination-container.is-background .el-pager li:not(.disabled).active {
  /*当前选中页数的样式进行修改*/
  background-color: #0bb197;
  color: #fff;
}

/* 详情弹窗 */
.dev-content-right .cell > img {
  width: 30px;
  height: 100%;
}
.detail-pop {
  .el-dialog__header {
    background-color: #0bb197;
    padding: 10px 20px;
  }
  .el-dialog__title {
    color: white;
  }
  .el-dialog__headerbtn .el-dialog__close {
    color: white;
    font-size: 18px;
  }
  .el-dialog__headerbtn {
    top: 15px;
  }
  .detail-content {
    display: flex;
    justify-content: space-between;
  }
  .el-dialog__body {
    padding: 0px 20px;
  }
}
</style>